package main

import (
	"ginEssential/common"
	"github.com/gin-gonic/gin"
	"github.com/spf13/viper"
	"os"
)
func main() {
	InitConfig()
	common.InitDB()
	//defer  db.Close()
	r := gin.Default()
	r = CollectRouter(r)
	port:=viper.GetString("server.port")
	r.Run(":"+port)
}

func InitConfig() {
	workDir,_:=os.Getwd() //获取工作目录
	viper.SetConfigName("application")
	viper.SetConfigType("yml")
	viper.AddConfigPath(workDir+"/config")
	err:=viper.ReadInConfig()
	if err!=nil{
		panic(err)
	}
}